package com.thtfpc.stroke.screening.util;

import com.thtfpc.stroke.screening.service.SampleDistributeServiceImp;

import java.util.Date;


public class CodeUtil {
    public static String generationCodeRecordId() {
        String prefixString = "1022";

        String year = DateConvertUtil.covvert2String(new Date(), "yy");
        String date = DateConvertUtil.covvert2String(new Date(), "MMddHHmmss");
        String random = RandomUtil.getRandomByRange(10, 99) + "";
        String macNum = "341";
        String seq = (System.currentTimeMillis() % 1000L) + "";
        StringBuffer code = new StringBuffer();
        String random2 = RandomUtil.getRandomByRange(10, 99) + "";
        code.append(prefixString).append(year).append(random).append(date).append(macNum).append(seq).append(random2);
        return code.toString();
    }

    public static String generationCodePatientId() {
        String prefixString = "2022";
        String year = DateConvertUtil.covvert2String(new Date(), "yy");
        String date = DateConvertUtil.covvert2String(new Date(), "MMddHHmmss");
        String random = RandomUtil.getRandomByRange(10, 99) + "";
        String macNum = "173";
        String seq = (System.currentTimeMillis() % 1000L) + "";
        StringBuffer code = new StringBuffer();
        String random2 = RandomUtil.getRandomByRange(10, 99) + "";
        code.append(prefixString).append(year).append(random).append(date).append(macNum).append(seq).append(random2);
        return code.toString();
    }

    public static String generationGroupID(String groupName ) {
        String groupSign="";
        if(SampleDistributeServiceImp.groups[0].equals(groupName)){
            groupSign="01";
        }else{
            groupSign="10";
        }
        String year = DateConvertUtil.covvert2String(new Date(), "yy");
        String date = DateConvertUtil.covvert2String(new Date(), "MMddHHmmss");
        String seq = (System.currentTimeMillis() % 1000L) + "";
        StringBuffer code = new StringBuffer();
        String random2 = RandomUtil.getRandomByRange(10, 99) + "";
        code.append(groupSign).append(year).append(date).append(seq);
        return code.toString();
    }


}

